package com.github.wenzi.deviltrainingfour.controller;

import com.github.wenzi.deviltrainingfour.dto.ArticleQueryDto;
import com.github.wenzi.deviltrainingfour.entity.Article;
import com.github.wenzi.deviltrainingfour.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping
    public String index(Model model,ArticleQueryDto dto){
        Page<Article> page = articleService.query(dto);
        model.addAttribute("page",page);
        return "client/index";
    }
}
